<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>

<div class="layui-form layuimini-form">

    <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>
</div>
<script src="../../js/common.js"></script>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script>
    function getQueryString(name) {
        let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        let r = window.location.search.substr(1).match(reg);
        if (r != null) {
            return decodeURIComponent(r[2]);
        }
        ;
        return null;
    }

    layui.use(['form', 'table', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer,
            table = layui.table,
            $ = layui.$;

        table.render({
            elem: '#currentTableId',
            url: '/vote/noVoteUser',
            toolbar: '#toolbarDemo',
            where: {
                itemId: getQueryString("itemId")
            },
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {field: 'name', title: '用户名'},
                {field: 'phone', title: '工号'},
            ]],
            page: false,
            skin: 'line',
            parseData: function (res) { //res 即为原始返回的数据
                checkLogin(res);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.total, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
        });


        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            table.reload('currentTableId', {
                where: {
                    itemId: getQueryString("itemId"),
                    sort: data.field.sort
                }
            }, 'data');

            return false;
        });

    });
</script>
</body>
</html>
